class Product < ActiveRecord::Base
  attr_accessible :category_id, :desc, :name, :price, :quantity  
  attr_accessor :quantity  # virtual attribute not persisted to db
  
  default_scope :order => 'name'

  belongs_to :categories
  has_many :inventories
  has_many :invoice_items

  validates :name, :presence => true, :uniqueness => true
  # validates :price, :numericality => {:greater_than_or_equal_to => 0.01}
  validates :category_id, :presence => true
end
